package com.windy.controller;

import com.windy.app.entity.Product;
import com.windy.app.vo.Result;
import com.windy.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("product")
public class ProductController {

    @Autowired
    private IProductService productService;

    @GetMapping("findProductById")
    public Product findProductById(@RequestParam(name = "id") Long id){
        return productService.findById(id);
    }

    @GetMapping("findAllProduct")
    public List<Product> findAllProduct(){
        return productService.findAllProduct();
    }


    @GetMapping("audit")
    public Result auditProduct(@RequestParam(name = "id") Long id){
        return productService.auditProduct(id);
    }

    @GetMapping("kcc")
    public Result<Product> kcc(@RequestParam(name = "id") Long id ,@RequestParam(name = "number") Integer number){
        System.out.println("number"+number);
        return this.productService.delStore(id,number);
    }

}
